home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / javax / accessibility / AccessibleText.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  5.2 KB  |  173 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)AccessibleText.java    1.20 98/08/26
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package javax.accessibility;
  16.  
  17.  
  18. import java.lang.*;
  19. import java.util.*;
  20. import java.awt.*;
  21. import javax.swing.text.*;
  22.  
  23.  
  24. /**
  25.  * <P>The AccessibleText interface should be implemented by all 
  26.  * classes that present textual information on the display.  This interface
  27.  * provides the standard mechanism for an assistive technology to access 
  28.  * that text via its content, attributes, and spatial location.  
  29.  * Applications can determine if an object supports the AccessibleText 
  30.  * interface by first obtaining its AccessibleContext (see {@link Accessible})
  31.  * and then calling the {@link AccessibleContext#getAccessibleText} method of 
  32.  * AccessibleContext.  If the return value is not null, the object supports this
  33.  * interface.
  34.  *
  35.  * @see Accessible
  36.  * @see Accessible#getAccessibleContext
  37.  * @see AccessibleContext
  38.  * @see AccessibleContext#getAccessibleText
  39.  *
  40.  * @version    1.13 01/20/98 07:53:43
  41.  * @author    Peter Korn
  42.  */
  43. public interface AccessibleText {
  44.  
  45.     /**
  46.      * Constant used to indicate that the part of text that should be
  47.      * retrieved is a character.
  48.      * 
  49.      * @see #getAtIndex
  50.      * @see #getAfterIndex
  51.      * @see #getBeforeIndex
  52.      */
  53.     public static final int CHARACTER = 1;
  54.  
  55.     /**
  56.      * Constant used to indicate that the part of text that should be 
  57.      * retrieved is a word.
  58.      * 
  59.      * @see #getAtIndex
  60.      * @see #getAfterIndex
  61.      * @see #getBeforeIndex
  62.      */
  63.     public static final int WORD = 2;
  64.  
  65.     /**
  66.      * Constant used to indicate that the part of text that should be 
  67.      * retrieved is a sentence.
  68.      * 
  69.      * @see #getAtIndex
  70.      * @see #getAfterIndex
  71.      * @see #getBeforeIndex
  72.      */
  73.     public static final int SENTENCE = 3;
  74.  
  75.     /**
  76.      * Given a point in local coordinates, return the zero-based index
  77.      * of the character under that Point.  If the point is invalid,
  78.      * this method returns -1.
  79.      *
  80.      * @param p the Point in local coordinates
  81.      * @return the zero-based index of the character under Point p; if 
  82.      * Point is invalid returns -1.
  83.      */
  84.     public int getIndexAtPoint(Point p);
  85.  
  86.     /**
  87.      * Determine the bounding box of the character at the given 
  88.      * index into the string.  The bounds are returned in local
  89.      * coordinates.  If the index is invalid an empty rectangle is returned.
  90.      *
  91.      * @param i the index into the String
  92.      * @return the screen coordinates of the character's the bounding box,
  93.      * if index is invalid returns an empty rectangle.
  94.      */
  95.     public Rectangle getCharacterBounds(int i);
  96.  
  97.     /**
  98.      * Return the number of characters (valid indicies) 
  99.      *
  100.      * @return the number of characters
  101.      */
  102.     public int getCharCount();
  103.  
  104.     /**
  105.      * Return the zero-based offset of the caret.
  106.      *
  107.      * Note: That to the right of the caret will have the same index
  108.      * value as the offset (the caret is between two characters).
  109.      * @return the zero-based offset of the caret.
  110.      */
  111.     public int getCaretPosition();
  112.  
  113.     /**
  114.      * Return the String at a given index. 
  115.      *
  116.      * @param part the CHARACTER, WORD, or SENTENCE to retrieve
  117.      * @param index an index within the text
  118.      * @return the letter, word, or sentence
  119.      */
  120.     public String getAtIndex(int part, int index);
  121.  
  122.     /**
  123.      * Return the String after a given index.
  124.      *
  125.      * @param part the CHARACTER, WORD, or SENTENCE to retrieve
  126.      * @param index an index within the text
  127.      * @return the letter, word, or sentence
  128.      */
  129.     public String getAfterIndex(int part, int index);
  130.  
  131.     /**
  132.      * Return the String before a given index.
  133.      *
  134.      * @param part the CHARACTER, WORD, or SENTENCE to retrieve
  135.      * @param index an index within the text
  136.      * @return the letter, word, or sentence
  137.      */
  138.     public String getBeforeIndex(int part, int index);
  139.  
  140.     /**
  141.      * Return the AttributeSet for a given character at a given index
  142.      *
  143.      * @param i the zero-based index into the text 
  144.      * @return the AttributeSet of the character
  145.      */
  146.     public AttributeSet getCharacterAttribute(int i);
  147.  
  148.     /**
  149.      * Returns the start offset within the selected text.
  150.      * If there is no selection, but there is
  151.      * a caret, the start and end offsets will be the same.
  152.      *
  153.      * @return the index into the text of the start of the selection
  154.      */
  155.     public int getSelectionStart();
  156.  
  157.     /**
  158.      * Returns the end offset within the selected text.
  159.      * If there is no selection, but there is
  160.      * a caret, the start and end offsets will be the same.
  161.      *
  162.      * @return the index into teh text of the end of the selection
  163.      */
  164.     public int getSelectionEnd();
  165.  
  166.     /**
  167.      * Returns the portion of the text that is selected. 
  168.      *
  169.      * @return the String portion of the text that is selected
  170.      */
  171.     public String getSelectedText();
  172. }
  173.